<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  title = join_title t("Upload Gradebook"), @context.name
  content_for :page_title, title
  css_bundle :slickgrid, :gradebook_uploads
  js_bundle :gradebook_uploads
%>

<h1><%= title %></h1>

<div id="spinner" style="height:250px"></div>

<form id="gradebook_importer_resolution_section" style="display:none;">
  <h3>{{#t}}There was some stuff I couldn't figure out with the data that you uploaded:{{/t}}</h3>
  <div class="student_section" style="display:none;">
    <h4>{{#t}}You uploaded rows for the following students, I couldn't decide which student in your class they are.  Please tell me which student they are.{{/t}}</h4>
    <table cellspacing="0" class="ui-widget ui-widget-content">
      <thead>
        <tr>
          <th class="ui-widget-header">{{#t}}Student in question{{/t}}</th>
          <th class="ui-widget-header">{{#t}}This person is really{{/t}}</th>
        </tr>
      </thead>
      <tbody>
        <tr id="student_resolution_template" style="display:none">
          <th class='name'>{{#t}}Some Guy{{/t}}</th>
          <td>
            <select name="student_-iterator-">
              <option value="">{{#t}}-- Choose student --{{/t}}</option>
              <option value="ignore" class="ignore">{{#t}}Not in my class, Ignore this row.{{/t}}</option>
            </select>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
  <div class="assignment_section" style="display:none">
    <h4>{{#t}}You uploaded some assignments that don't appear to be in your gradebook before now.  Please tell me if it is a new assignment, or if it represents an existing assignment.{{/t}}</h4>
    <table cellspacing="0" class="ui-widget ui-widget-content">
      <thead>
        <tr>
          <th class="ui-widget-header">{{#t}}Assignment in question{{/t}}</th>
          <th class="ui-widget-header">{{#t}}This Assignment is{{/t}}</th>
        </tr>
      </thead>
      <tbody>
        <tr id="assignment_resolution_template" style="display:none;">
          <th class='title'>{{#t}}Equity Indices Quiz{{/t}}</th>
          <td>
            <select name="assignment_-iterator-">
              <option value="">{{#t}}-- Choose assignment --{{/t}}</option>
              <option value="new" class="new">{{#t}}A new assignment{{/t}}</option>
              <option value="ignore" class="ignore">{{#t}}Bogus, ignore it{{/t}}</option>
            </select>
            <span class="points_possible_section">
              <label for="points_possible">{{#t}}Points Possible{{/t}}</label>
              <input id="points_possible" type="text" class="points_possible" />
            </span>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
  <div class="button-container">
    <button type="submit" class="btn"><%= t('buttons.continue', "Continue %{icon}", :icon => raw('&rarr;')) %></button>
  </div>
</form>

<div id="no_changes_detected" style="display:none;">
  <h2>{{#t}}There were no changes detected in the gradebook you uploaded.{{/t}}</h2>
  <p>
  <%= link_to(t('links.back', "Go back to Gradebook"), polymorphic_url([@context, 'gradebook'])) %>
  </p>

</div>

<%= form_tag({}, {:method => "put", :id => "gradebook_grid_form", :style => "display:none;"}) do %>
  <div id="gradebook_uploader_container">
    <div id="grid">
      <div id="gradebook_grid_header"></div>
      <div id="gradebook_grid"></div>
    </div>
  </div>

  <input type="hidden" name="json_data_to_submit" value="" />
  <div class="button-container" style="padding-left:7px;">
    <button type="submit" class="btn">{{#t}}Save Changes{{/t}}</button>
    <%= link_to t('#buttons.cancel', "Cancel"), :back , :class => "btn btn button-secondary" %>
    <span id="assignments_without_changes_alert" style="display:none; margin-left: 50px;">{{#t}}Note: You uploaded some assignments that had no grade changes detected. They have been hidden.{{/t}}</span>
  </div>
<% end -%>

<div id="prevented-new-assignment-in-closed-period" style="display:none;">
  <h4>{{#t}}Some assignments could not be created because they would fall in a closed grading period.{{/t}}</h4>
</div>

<div id="prevented-grading-ungradeable-submission" style="display:none;">
  <h4>{{#t}}Some submissions are not gradeable; grade changes for those submissions have been ignored.{{/t}}</h4>
</div>

<style>
  /*keep this here because jquery.rule needs it to stick in dynamic styles for the slick.grid to keep all of the columns the same width*/
</style>
